package edu.mit.media.fv.components
{
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	
	public class FVSqaureButton extends Sprite
	{
		private static var filter:BevelFilter = new BevelFilter();
		private static var infilter:BevelFilter = new BevelFilter(4,45,0,1,0xFFFFFF,1,4,4,1,1, BitmapFilterType.INNER);
		private var r:Sprite;
		private var s:DisplayObject;
		private var isPressed:Boolean = false;
		
		public function FVSqaureButton(x:int = 0, y:int = 0, width:int = 100, height:int = 100, text:String = "", icon:DisplayObject = null)
		{
			super();
			this.x = x;
			this.y = y;
			r = new Sprite();
			r.graphics.beginFill(0x888888, 1.0);
			r.graphics.drawRoundRect(0,0,width,height,15,15);
			r.graphics.endFill();
			this.addChild(r);
			
			if(icon == null){
				s = new Sprite();
			}else{
				s = icon;
				s.x = width/4;
				s.y = height/4;
				s.width = width/2;
				s.height = height/2;
			}
			this.addChild(s);
			
			r.filters = [filter];
			s.filters = [infilter];
			
			this.addEventListener(MouseEvent.MOUSE_UP, processMouseUp);
			this.addEventListener(MouseEvent.MOUSE_OUT, processMouseOut);
			this.addEventListener(MouseEvent.MOUSE_DOWN, processMouseDown);
		}
		
		private function processMouseUp(event:MouseEvent):void{
			if(this.isPressed){
				
			}
			this.isPressed = false;
			r.filters = [filter];
		}
		private function processMouseDown(event:MouseEvent):void{
			this.isPressed = true;
			r.filters = [infilter];
		}
		private function processMouseOut(event:MouseEvent):void{
			this.isPressed = false;
			r.filters = [filter];
		}

	}
}